<?php /*
	
*/ ?>
<?
// include config file.
include("system/config.inc.php");

// IF admin is not logged in then it will redirect to the adminlogin page.
if(!isset($_SESSION['adminuserid']))
{
	header("location:adminlogin.php?msg=logfirst");
	die();
}

// INSERT into database.
if(isset($_REQUEST['Submit']) && trim($_REQUEST['Submit']) == "Submit")
{
	//$varsubject = $_REQUEST['varsubject'];
	$varstatus = $_REQUEST['status'];	
	
	$insert="INSERT INTO `tblorderstatus` (`varstatus`)	VALUES ('$varstatus')";
	
	//echo $insert;
	//die();
	
	$sql=$obj_db->insert($insert);	
	
	header("location:orderstatusmodule.php");
	die();
}	

// DELETE record from database
if(isset($_REQUEST['a']) && trim($_REQUEST['a'])==3)
{
	if(isset($_REQUEST['intid']) && trim($_REQUEST['intid']!=""))
	{	
	
		
		$screen_id =  $_REQUEST['intid'];
		$sql_del = "Delete from tblorderstatus where intid ='$screen_id'";
		
		//echo $sql_del;
		//die();
		
		$delete = mysql_query($sql_del);
		
		header("location:orderstatusmodule.php");
		die();
	}
}

// UPDATE the record

//$varsubject1="";
$status1="";

$action=1;

if((isset($_REQUEST['a']) && trim($_REQUEST['a'])==2) && (!(isset($_REQUEST['Submit']) && 
trim($_REQUEST['Submit']) == "Submit")))
{
 	if(isset($_REQUEST['intid']) && trim($_REQUEST['intid'])!="")
 	{
		$screen_id =  $_REQUEST['intid'];
		$sql = "select * from tblorderstatus where intid ='$screen_id'";
		$result = $obj_db->select($sql);
		if(count($result)<=0)
		{
			echo " No Record Found!<br>";
			die();
		}
		if($result)
		{
			foreach($result as $row)
			{
				$status1 = $row['varstatus'];

				//$vartext1 = $row['vartext'];
				
				$action=2;
			}
		}
		if(isset($_REQUEST['Submit']) && trim($_REQUEST['Submit']) == "Update")
		{
			$varstatus = $_REQUEST['status'];			
					
			$sql_upd ="UPDATE tblorderstatus SET `varstatus` = '$varstatus' WHERE intid ='$screen_id'";			
			//echo $sql_upd;
			//die();
			
			$result = $obj_db->sql_query($sql_upd);
			$action=1;
			
			header("location:orderstatusmodule.php");
			die();
		}
	}
}



// change status Approve or Not Approve
if(isset($_REQUEST['status']) && trim($_REQUEST['status']) == 0)
{
	if(isset($_REQUEST['intid']) && trim($_REQUEST['intid']!=""))
	{
		$screen_id=$_REQUEST['intid'];
		$sql="update tblorderstatus set intstatus = 1 where intid = $screen_id";
		
		$update = $obj_db->sql_query($sql);
		
		header("location:orderstatusmodule.php");
		die();
	}
}
if(isset($_REQUEST['status']) && trim($_REQUEST['status']) == 1)
{
	if(isset($_REQUEST['intid']) && trim($_REQUEST['intid']!=""))
	{
		$screen_id=$_REQUEST['intid'];
		$sql="update tblorderstatus set intstatus = 0 where intid = $screen_id";
		
		$update = $obj_db->sql_query($sql);
		
		header("location:orderstatusmodule.php");
		die();
	}
}



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>ibccomputers.com::Admin</title>
<link href="css/pain.css" rel="stylesheet" type="text/css" />
<link href="css/dunt.css" rel="stylesheet" type="text/css" />
</head>
<body >


<script language="javascript" src="js/orderstatusmodule.js"></script>


<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="middlebackground">
<tr>
<td align="center" valign="top" ><? include(INC."top.php");?></td>
</tr>
<tr>
<td valign="top">

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><table width="100%"  border="0" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td valign="top">
<?php
if(isset($_REQUEST['script']))
{
	if(trim($_REQUEST['script'])=='addorderstatusmodule' || trim($_REQUEST['script'])=='editorderstatusmodule')
	{
	?>
<form action="" method="post" enctype="multipart/form-data" name="orderstatusmodule" >
  <table width="50%" align="center" cellpadding="2" cellspacing="2" class="border">
	<tr class="bg1">
	<td align="center"><strong>
	  <?php if($_REQUEST['script']=='addorderstatusmodule'){echo "Add Status...";}
	if($_REQUEST['script']=='editorderstatusmodule'){echo "Edit Status...";}?>
	</strong></td>
	</tr>	
	<tr >
	  <td>	  
	  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
			<?php
			if(isset($_REQUEST['mail_add']))
			{
				$email=$_REQUEST['mail_add'];
			}
			?>
			<tr>
			  <td width="118">&nbsp;</td>
			  <td align="right">(* All fields are Required)</td>
			</tr>
			<tr>
			  <td align="right" class="sltimg">*Status : </td>
			  <td><input name="status" type="text" id="status" value="<?=$status1;?>" size="35" /></td>
			</tr>
			
			<?php
			if(isset($_REQUEST['forum']))
			{
				$forumlogin=$_REQUEST['forum'];
			}
			?>
						
			<?php
			if(isset($_REQUEST['password']))
			{
				$password=$_REQUEST['password'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['firstname']))
			{
				$firstname=$_REQUEST['firstname'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['lastname']))
			{
				$lastname=$_REQUEST['lastname'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['birthdate']))
			{
				$dateofbirth=$_REQUEST['birthdate'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['feet']))
			{
				$feet=$_REQUEST['feet'];
			}
			if(isset($_REQUEST['inch']))
			{
				$inch=$_REQUEST['inch'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['lbs']))
			{
				$weight=$_REQUEST['lbs'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['add_1']))
			{
				$address1=$_REQUEST['add_1'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['add_2']))
			{
				$address2=$_REQUEST['add_2'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['city']))
			{
				$city=$_REQUEST['city'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['zipcode']))
			{
				$zipcode=$_REQUEST['zipcode'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['phone']))
			{
				$phone=$_REQUEST['phone'];
			}
			?>
			
			<?php
			if(isset($_REQUEST['cell']))
			{
				$cell=$_REQUEST['cell'];
			}
			?>
			<tr>
			  <td>&nbsp; </td>
			  <td>&nbsp;</td>
			</tr>
			<tr>
			  <td colspan="2" align="center">
				<input name="Submit" type="submit" class="btn" 
				onClick="return check();" value="<?php echo ($action==2) ? "Update":"Submit"; ?>">	</td>
			</tr>
	  	</table> 	  </td>
	</tr>
	</table>
	<?
	}
}
else
{
?>

<table width="60%" border="0" align="center" cellpadding="1" cellspacing="0">
	  <tr class="bg1">
		<td height="20">
		<table border="0" align="center" cellpadding="1" cellspacing="0">
			<tr align="center" class="line_top">
				<td width="100%" align="left"><strong>Order Status...</strong></td>
				<td width="100%" align="right">
				 	<a class="link" href="orderstatusmodule.php?script=addorderstatusmodule"><img src="images/new.jpg" alt="New" border="0" /></a>				</td>
			</tr>
		</table>
		</td>
	  </tr>

		<td class="box">
		<table width="100%"  border="0" align="center" cellpadding="2" cellspacing="2" class="border">
		  <tr class="tblbg3">
		  	<td align="center">No.</td>
			<!--<td align="center">ID</td>-->
			<td align="center">Status</td>
			
			
			<!--<td align="center">Status</td>-->
			<td align="center">Edit</td>
			<td align="center">Delete</td>
		  </tr>
	<?php
		/**************************************
				PAGING CODE START
		**************************************/
		//$rowperpage=23;
		$tablename="tblorderstatus";
		$per_page_keywords= "";
		$per_page_sorts= "";
		include("system/paging.inc.php");

		/**************************************
				PAGING CODE ENDING
		**************************************/

	
	$sql_select = "select * 
	from  ".$tablename."
	Limit ".($page_no*$row_per_page).",".$row_per_page;
	$sql = $obj_db->select($sql_select);
	if($sql)
	{
	$i=0;
	for($j=0;$j<count($sql);$j++)
	 { 
		$screen_id=$sql[$j]['intid'];
		 $i=$i+1;
		  ?>
			<tr align="center" class="<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>" onMouseOver="this.className='Hrhover';"  
				onMouseOut="this.className='<?php echo ($i%2==0)?"Hrnormal":"Hralter"; ?>';">        
				<td><?php echo $i; ?>.</td>
				<!--<td><?php echo $sql[$j]['intid']; ?></td>-->
				<td><?php echo $sql[$j]['varstatus']; ?></td>
				
				
				
				
				<!--<td><table border="0" cellspacing="0" cellpadding="0" align="center">
				  <tr><?php 
					/*if($sql[$j]['intstatus']==0)
					{
						echo "<td><a class='aa' href='orderstatusmodule.php?status=0&intid=$screen_id'>Not Approve</a></td>";	
					} 
					if($sql[$j]['intstatus']==1)
					{
						echo "<td><a class='aa' href='orderstatusmodule.php?status=1&intid=$screen_id'>Approve</a></td>";	
					} */
				  ?> </tr>
				</table></td>-->
				
				<td><a class="link" Title="Click here to Edit" href="orderstatusmodule.php?script=editorderstatusmodule&a=2&intid=<?=$screen_id;?>">
				<img src="images/edit.bmp" alt="Edit" border="0"></a></td>
				<td><a Title="Click here to Delete" class="link" href="orderstatusmodule.php?a=3&intid=<?=$screen_id;?>" 
				onClick="return confirm('Are you sure to delete this record ?');">
				<img src="images/delete.bmp" alt="Delete" border="0"></a></td>	
			</tr>
			
			<tr>
			<?php 
			}
		?>
			  <td colspan="10" ><div align="center">
			  <? pagindet_atbotttom_page($div_page_no,$page_no,$req_querystr,$total_db_rec,$row_per_page); ?>
              </div></td>
		  </tr>
		  <?
	}	
   ?>
  </table></td>
  </tr>
</table>	
</form>
<?
}
?></td>
      </tr>
    </table></td>
  </tr>
</table>

</td>
</tr>
<tr><td align="center">&nbsp;</td>
</tr>
</table>
</body>
</html>